package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ArticleComments;
import com.ruoyi.system.service.IArticleCommentsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 文章评论Controller
 * 
 * @author ruoyi
 * @date 2025-07-15
 */
@RestController
@RequestMapping("/system/articleComments")
public class ArticleCommentsController extends BaseController
{
    @Autowired
    private IArticleCommentsService articleCommentsService;

    /**
     * 查询文章评论列表
     */
    @PreAuthorize("@ss.hasPermi('system:articleComments:list')")
    @GetMapping("/list")
    public TableDataInfo list(ArticleComments articleComments)
    {
        startPage();
        List<ArticleComments> list = articleCommentsService.selectArticleCommentsList(articleComments);
        return getDataTable(list);
    }

    /**
     * 导出文章评论列表
     */
    @PreAuthorize("@ss.hasPermi('system:articleComments:export')")
    @Log(title = "文章评论", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ArticleComments articleComments)
    {
        List<ArticleComments> list = articleCommentsService.selectArticleCommentsList(articleComments);
        ExcelUtil<ArticleComments> util = new ExcelUtil<ArticleComments>(ArticleComments.class);
        util.exportExcel(response, list, "文章评论数据");
    }

    /**
     * 获取文章评论详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:articleComments:query')")
    @GetMapping(value = "/{articleCommentId}")
    public AjaxResult getInfo(@PathVariable("articleCommentId") Long articleCommentId)
    {
        return success(articleCommentsService.selectArticleCommentsByArticleCommentId(articleCommentId));
    }

    /**
     * 新增文章评论
     */
    @PreAuthorize("@ss.hasPermi('system:articleComments:add')")
    @Log(title = "文章评论", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ArticleComments articleComments)
    {
        return toAjax(articleCommentsService.insertArticleComments(articleComments));
    }

    /**
     * 修改文章评论
     */
    @PreAuthorize("@ss.hasPermi('system:articleComments:edit')")
    @Log(title = "文章评论", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ArticleComments articleComments)
    {
        return toAjax(articleCommentsService.updateArticleComments(articleComments));
    }

    /**
     * 删除文章评论
     */
    @PreAuthorize("@ss.hasPermi('system:articleComments:remove')")
    @Log(title = "文章评论", businessType = BusinessType.DELETE)
	@DeleteMapping("/{articleCommentIds}")
    public AjaxResult remove(@PathVariable Long[] articleCommentIds)
    {
        return toAjax(articleCommentsService.deleteArticleCommentsByArticleCommentIds(articleCommentIds));
    }
}
